using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TablePaymentDao:DaoBase<TablePayment>
    {
        public override void AddPrimaryIndex(TablePayment model)
        {
            cachePrimary[model.paymentId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TablePayment.txt";
        }

        protected override TablePayment ParseRowData(string[] rowData)
        {
            TablePayment data = new TablePayment();
			data.paymentId = rowData [0];
			data.channelIdList = rowData [1];
			data.shopId = rowData [2];
			data.paymentType = rowData [3];

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.money = 0;
            }
            else
            {
                data.money = double.Parse(rowData[4]);
            }
			data.moneyType = rowData [5];

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.charge = 0;
            }
            else
            {
                data.charge = int.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.free = 0;
            }
            else
            {
                data.free = int.Parse(rowData[7]);
            }
			data.paymentName = rowData [8];
			data.paymentDesc = rowData [9];

            return data;
        }



        public override void AddTwoIndex(TablePayment model)
        {
            string key = GetUnionKey(model.shopId.ToString(),model.paymentType.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TablePayment>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
